#include <iostream>
#include <memory>

//#include "shared_ptr.h"
#include "demo.h"

using namespace std;

class A
{
public:
	A(int a1, int a2)
		:_a1(a1)
		, _a2(a2)
	{}

	~A()
	{
		cout << "~A()" << endl;
	}
	//private:
	int _a1 = 1;
	int _a2 = 1;
};


int main()
{
	MySharedPtrDemo::shared_ptr<A> sp1(new A(1, 1));
	MySharedPtrDemo::shared_ptr<A> sp2(sp1);

	cout << sp1.use_count() << endl;

	MySharedPtrDemo::shared_ptr<A> sp3(new A(2, 2));
	MySharedPtrDemo::shared_ptr<A> sp4(sp3);
	MySharedPtrDemo::shared_ptr<A> sp5(sp4);
	cout << sp3.use_count() << endl;

	sp1 = sp3;
	//sp2 = sp3;
	//sp3 = sp4;

	//MySharedPtr::shared_ptr<A> sp6(new A(3, 3));
	//sp6 = sp6;
	//sp3 = sp4;

	return 0;
}